home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0018_Find Data at end of EXE.pas < prev    next >
Pascal/Delphi Source File  |  1993-07-16  |  3KB  |  69 lines

  1. ===========================================================================
  2.  BBS: Canada Remote Systems
  3. Date: 06-24-93 (15:37)             Number: 27580
  4. From: ROB PERELMAN                 Refer#: NONE
  5.   To: ALL                           Recvd: NO  
  6. Subj: End of EXE                     Conf: (1221) F-PASCAL
  7. ---------------------------------------------------------------------------
  8. This is a unit I wrote but it crashed a few times on me, so here is an
  9. updated unit for anyone's use.  Remember not to use it from the TP
  10. editor because if you compile to memory, PARAMSTR(0) is the editor, and
  11. if you compile to disk, you will not have any data.
  12.  
  13. Unit ExeEnd;
  14.  
  15. Interface
  16.  
  17. Var EndOfExe: LongInt; {Shows the end of the EXE file}
  18.     ExeFile: File; {The EXE file positioned at the end}
  19.     Data: Boolean; {If there is data after the EXE}
  20.  
  21. Implementation
  22.  
  23. Type EXEHeader=Record
  24.       ID: Word;                  { EXE file id }
  25.       ByteMod: Word;             { Load module image size mod 512 }
  26.       Pages: Word;               { File size (including header) div 512 }
  27.       RelocItems: Word;          { Number of relocation table items }
  28.       Size: word;                { Header size in 16-byte paragraphs }
  29.       MinParagraphs: Word;       { Minimum number of paragraphs above program }
  30.       MaxParagraphs: Word;       { Maximum number of paragraphs above program }
  31.       StackSeg: Word;            { Displacement of stack segment }
  32.       SPReg: Word;               { Initial SP register value }
  33.       CheckSum: Integer;         { Word checksum - negative sum (not used) }
  34.       IPReg: Word;               { Initial IP register value }
  35.       CodeSeg: Word;             { Displacement of code segment }
  36.       FirstReloc: Word;          { First relocation item }
  37.       OvlN: Word                 { Overlay number }
  38.     End;
  39.  
  40. Const CorrectExe=$5A4D;
  41.  
  42. Var Exe: EXEHeader;
  43.     ReadIn: Integer;
  44.     OldExitProc: Pointer;
  45.  
  46. Procedure CloseExe; Far;
  47. Begin
  48.   ExitProc:=OldExitProc;
  49.   Close(ExeFile);
  50. End;
  51.  
  52. Begin
  53.   OldExitProc:=ExitProc;
  54.   ExitProc:=@CloseExe;
  55.   Assign(ExeFile, ParamStr(0));
  56.   Reset(ExeFile, 1);
  57.   BlockRead(ExeFile, Exe, SizeOf(Exe), ReadIn);
  58.   With Exe do If (ReadIn<>SizeOf(Exe)) or (ID<>CorrectExe) then EndOfExe:=0
  59.     Else EndOfExe:=Pages*512+ByteMod-512;
  60.   Seek(ExeFile, EndOfExe);
  61.   Data:=Not EOF(ExeFile);
  62. End.
  63.  
  64.  * QMPro 1.50 4 * "Call waiting", great if you have two friends
  65.  
  66.  
  67. --- WM v3.00/92-0215
  68.  * Origin: High Country East, Ramona, CA (619)-789-4391  (1:202/1308.0)
  69.